<template>
	<view class="viewbox auto p-top30">
		
		<view class="row j-sb a-center padding20-30 bg28 bor_radius_20 m-bot20">
			<view class="d-flex a-center">
				<text class="white size30 ">头像</text>
			</view>
			<image  @tap="chooseImg()" class="headIcon bor_radius" :src="showSrc" ></image>
		</view>
		<view class="row j-sb a-center padding30 bg28 bor_radius_20 m-bot20" @tap="go('SetNickname?name='+userInfo.nick_name)">
			<view class="d-flex a-center">
				<text class="white size30 ">昵称</text>
			</view>
			<view class="d-flex a-center">
				<text class="white size30">{{userInfo.nick_name}}</text>
				<view class="iconfont icon-a-zujian32 color_ccc size16 m-left10"></view>
			</view>
		</view>
		<view class="row j-sb a-center padding30 bg28 bor_radius_20 m-bot20" >
			<view class="d-flex a-center">
				<text class="white size30 ">手机号</text>
			</view>
			<text class="white size30">{{userInfo.phone}}</text>
		</view>
		
		<!-- <view class="line"></view>
		<view class="iptBox flexBox">
			<view class="label">头像</view>
			<view class="rBox flexBox">
				<image  @tap="chooseImg()" class="headIcon" :src="showSrc" mode="aspectFill"></image>
			</view>
		</view>

		<view class="iptBox flexBox" @tap="go('SetNickname?name='+userInfo.nick_name)">
			<view class="label">昵称</view>
			<view class="rBox flexBox">
				<view class="">{{userInfo.nick_name}}</view>
				<image class="arrowIcon" src="../../static/img/my/right.png" mode=""></image>
			</view>
		</view>
		
		<view class="iptBox flexBox">
			<view class="label">手机号</view>
			<view class="rBox flexBox p-right20">
				<view class="">{{userInfo.phone}}</view>
			</view>
		</view> -->

		
		
		
<!-- 		
		<view class="box">
			<view class="p1">以太坊(ETH)</view>
			<view class=" iptBox1  flexBox">
				<view class="label">我的地址</view>
				<view class="center">
					{{userInfo.wallet_address}}
					<image class="copy" @tap="copy(userInfo.wallet_address)" src="../../static/img/my/copy.png" mode=""></image>
				</view>
			</view>
			<view class=" iptBox1  flexBox">
				<view class="label">我的密钥</view>
				<view class="center">
					{{userInfo.wallet_private_key}}
					<image class="copy" @tap="copy(userInfo.wallet_private_key)" src="../../static/img/my/copy.png" mode=""></image>
				</view>
			</view>
		</view>
		
		<view class="box">
			<view class="p1">币安智能链(BSC)</view>
			<view class=" iptBox1  flexBox">
				<view class="label">我的地址</view>
				<view class="center">
					{{userInfo.bsc_wallet_address}}
					<image class="copy" @tap="copy(userInfo.bsc_wallet_address)" src="../../static/img/my/copy.png" mode=""></image>
				</view>
			</view>
			<view class=" iptBox1  flexBox">
				<view class="label">我的密钥</view>
				<view class="center">
					{{userInfo.bsc_private_key}}
					<image class="copy" @tap="copy(userInfo.bsc_private_key)" src="../../static/img/my/copy.png" mode=""></image>
				</view>
			</view>
		</view>
		
		<view class="box">
			<view class="p1">火币生态链(HECO)</view>
			<view class=" iptBox1  flexBox">
				<view class="label">我的地址</view>
				<view class="center">
					{{userInfo.ht_wallet_address}}
					<image class="copy" @tap="copy(userInfo.ht_wallet_address)" src="../../static/img/my/copy.png" mode=""></image>
				</view>
			</view>
			<view class=" iptBox1  flexBox">
				<view class="label">我的密钥</view>
				<view class="center">
					{{userInfo.ht_private_key}}
					<image class="copy" @tap="copy(userInfo.ht_private_key)" src="../../static/img/my/copy.png" mode=""></image>
				</view>
			</view>
		</view>
		
 -->	
 </view>
</template>

<script>
	export default {
		data() {
			return {
				showSrc: "",
				// nick_name: '',
				userInfo: {},
			}
		},
		onShow() {
			this.getMemInfo();
		},
		onLoad() {
		},
		methods: {
			show(imgs){
				uni.previewImage({
					urls: [imgs],
					longPressActions: {
						itemList: ['更换图片', '保存图片'],
						success: (data)=> {
							if(data.tapIndex === 1){
								console.log(data.tapIndex)
								uni.saveImageToPhotosAlbum({
									filePath: imgs,
									success: ()=> {
										uni.showToast({
											title: '保存成功',
											icon: "none"
										});
									}
								})
							} else{
								console.log(data.tapIndex)
								this.chooseImg();
							}
							
						},
						fail: function(err) {
							console.log(err.errMsg);
						}
					}
				});
			},
			getMemInfo() {
				this.$http.get('user/userInfo').then(res => {
					if (res.code == 1) {
						this.userInfo = res.data;
						this.showSrc = res.data.head_image
					}
				})
			},
			editInfo() {
				let data = {
					nick_name: this.userInfo.nick_name,
					head_image: this.showSrc
				}
				this.$http.post('user/editUserInfo', data).then(res => {
					if (res.code == 1) {
						this.toast(res.msg);
						setTimeout(() => {
							uni.navigateBack({
								delta: 2
							})
						}, 1200)
					} else {
						this.toast(res.msg);
					}
				})
			},
			chooseImg() {
				let _this = this;
				uni.chooseImage({
					count: 1,
					sizeType: ['original'],
					success: (res) => {
						console.log(res)
						let tempFilePaths = res.tempFilePaths;
						uni.uploadFile({
							url: _this.baseUrl + 'upload/fileUpload',
							filePath: tempFilePaths[0],
							name: 'image',
							header: {
								'token': uni.getStorageSync("token")
							},
							success: (res1) => {
								var result = JSON.parse(res1.data);
								if (result.code == 1) {
									_this.showSrc = result.data.path;
									_this.editInfo()
								} else {
									_this.toast('上传失败');
								}
							}
						});
					}
				});
			},
		}
	}
</script>
<style>
	page {
		background-color: #1e201f;
	}
</style>
<style lang="scss" scoped>
	.headIcon{
		width:100rpx;
		height: 100rpx;
	}

</style>
